home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16219 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: inforamp.net!usenet
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Inheritance: Accessing members of base classes for assignment in derived classes
  5. Date: Wed, 10 Apr 1996 01:44:40 GMT
  6. Organization: InfoRamp Inc., Toronto, Ontario (416) 363-9100
  7. Message-ID: <4kep9o$6ci@sam.inforamp.net>
  8. References: <4k7cv8$h4m@dfw-ixnews5.ix.netcom.com>
  9. NNTP-Posting-Host: ts11-09.tor.istar.ca
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. guerino1@ix.netcom.com(Frank Guerino ) wrote:
  13.  
  14. >    Instruction& Instruction::operator=(const Instruction& x){
  15. >        char *tmp;
  16. >        strcpy(tmp, x.get_instruct());
  17.  
  18.     Note that x is a const class and get_instruct is not a const member.
  19. When you have a const class you can only access const members.  Thus,
  20. you have to make the function const also, try...
  21.         char *get_instruct() const { return String::get(); }
  22. and the save would go for the get statement...
  23.         char *get() const { return str; }
  24.  
  25. Hope this solves your problem.
  26.  
  27.  
  28. Agrivar
  29.  
  30. aka Randy Charles Morin,
  31. MiddleWorld SoftWare,
  32. Satisfying Your Bit and Bytes,
  33. Canada 1-800-363-3780 
  34. Other  1-905-279-2087
  35. eMail  rmorin@inforamp.net
  36.  
  37.